package com.gmail.dengtao.joe.group.transport;

import com.gmail.dengtao.joe.group.interceptor.InterceptorStack;

public interface ChannelReceiver {

	/**
     * Start listening for incoming messages on the host/port
	 * @param receiverLock 
     * @throws java.io.IOException
     * @since 1.0
     */
    public void start(Object receiverLock) throws Exception;

    /**
     * Stop listening for messages
     * @since 1.0
     */
    public void stop() throws Exception;
	
    /**
	 * Get idle time for read in seconds.
	 * @return
	 * @since 1.0
	 */
	public int getIdleTimeForRead();

	/**
	 * Set idle time for read in seconds, you should call this method before {@link ChannelReceiver#start()}.
	 * @param idleTimeForRead
	 * @since 1.0
	 */
	public void setIdleTimeForRead(int idleTimeForRead);

	/**
	 * Get current selector's timeout
	 * @return current selector's timeout in ms
	 * @since 1.0
	 */
	public int getSelectTimeout();

	/**
	 * Set selector's timeout, you should call this method before {@link ChannelReceiver#start()}.
	 * @param selectTimeout ms
	 * @since 1.0
	 */
	public void setSelectTimeout(int selectTimeout);
	
	/**
	 * Get receive buffer capacity of current buffer's capacity, in bytes.
     * @return receiveBufferSize capacity of current buffer's capacity, in bytes
     * @since 1.0
     */
    public int getReceiveBufferSize();
    
	/**
     * Allocates a new byte buffer. 
     * The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined. It will have a backing array, and its array offset will be zero.
     * you should call this method before {@link ChannelReceiver#start()}.
     * @param receiveBufferSize capacity The new buffer's capacity, in bytes
     * @throws IllegalArgumentException If the capacity is a negative integer
     * @since 1.0
     */
	public void setReceiveBufferSize(int receiveBufferSize);

	public InterceptorStack getInterceptorStack();

	public void setInterceptorStack(InterceptorStack interceptorStack);

	public String getHost();

	int getPort();

}